<style type="text/css">
.order_admin_menu {
	border: 1px solid #ddd;
	width: 40px;
	height: 15px;
	line-height: 15px;
	text-align: center;	
}
.save_img {
	width: 13px;
	height: 13px;
	border: none;
}
</style>
<!-- js validate form  -->
<script type="text/javascript">
function submitform()
{
  document.myform.submit();
}
</script>
<!-- js ajax -->
<script type="text/JavaScript">
	$(document).ready(function(){
		$('.delete_input_head').click(function(){
			var val = [];
		    $(':checkbox:checked').each(function(i){
		      val[i] = $(this).val();
		    }); 	    
			$.post(		
				'<?php echo base_url(); ?>back_end/category_product_2/load',
				{
				    value_all: val
				},
				function (data)
				{
					$('#load').html(data);
				}
					
			);
		});
	});
</script>

<?php
	if (isset($success_vl)) {
		echo $success_vl;
	} 
?>
		<div class="content_head">
			<?php echo $title; ?>
		</div>	
		<div class="content_ct">
			<div class="content_ct_search">
				<table class="content_ct_search_tbl"  width="100%">
					<form  method="POST" onsubmit="return check_form();" action="<?php echo base_url() ?>back_end/category_product_2/search">    
						<tr>
							<td width="15%">
								<span>Danh mục sản phẩm cấp 1: </span>
							</td>
							<td width="20%">
								<select name="parent_id" class="content_ct_search_tblselect" >
									<option value="0">------ Chọn danh mục sản phẩm cha ------</option>
									<?php
										foreach ($ct_1 as $ct_1_arr) { 
									?>
									<option value="<?php echo $ct_1_arr['id']; ?>"><?php echo $ct_1_arr['name'];  ?></option>
									<?php
										} 
									?>
								</select>
							</td>
							<td width="65%"></td>
						</tr>
						<tr>
							<td width="15%">
								<span>Danh mục sản phẩm cấp 2: </span>
							</td>
							<td width="20%">
								<input  class="content_ct_search_tbltxt" name="nameSearch" value="<?php if(isset($_SESSION['like_category_product_2'])){ echo $_SESSION['like_category_product_2']['name']; } ?>" type="text" />
							</td>
							<td width="65%"></td>
						</tr>
						<tr>
							<td></td>
							<td>
								<input id="input_checkbox_2" style="cursor:pointer;" type="submit" name="formSearch" value="Tìm kiếm" />
								<input style="cursor:pointer;" type="reset" value="Reset" />
							</td>
							<td></td>
						</tr>
					</form>
				</table>			
			</div>
			<!-- end content_ct_search -->

       		<div class="content_ct_show">
				<div class="content_ct_show_abs">
					<?php echo $this->session->flashdata('msview'); ?>
				</div>
				<div class="content_ct_show_paging">
					&nbsp;
				</div>
				
				<form name="myform" id="frmForm" method="POST" action="<?php echo base_url()?>back_end/category_product_2/order" >
				<div class="content_ct_show_head">
					<input class="delete_input_head" type="button" value="Xóa" />
					<a class="add_new" href="<?php echo base_url()?>back_end/category_product_2/add">Thêm mới</a>
					<span style="padding-left: 5px; color: #FF9933;" class="count_check"></span>
				</div>
				
				<div id="load">
					<div class="content_ct_show_ct">
						<table class="content_ct_show_ct_tbl" width="100%">
		                	<tr class="content_ct_show_ct_tbl_top">
			                    <td width="3%"><input type="checkbox" class="input_checkall" /></td>
			                    <td width="3%">
			                    	<a class="link_change" href="<?php echo base_url() ?>back_end/category_product_2/sort/id/<?php echo $sort; ?>">ID</a>
			                    </td>
	                            <td width=20%">
			                    	<a class="link_change" title="Click để sắp xếp" href="<?php echo base_url() ?>back_end/category_product_2/sort/name/<?php echo $sort; ?>">
				                		Tên danh mục sản phẩm
				                	</a>
			                    </td>
			                    <td width=20%">
			                    	<a class="link_change" title="Click để sắp xếp" href="<?php echo base_url() ?>back_end/category_product_2/sort/parent_id/<?php echo $sort; ?>">
				                		Danh mục cha
				                	</a>
			                    </td>
		                       <td width="30%">
			                    	<a class="link_change">
				                		Từ khóa mô tả
				                	</a>
			                    </td>
			                    <td width="8%">
									<a class="link_change" href="<?php echo base_url() ?>back_end/category_product_2/sort/order/<?php echo $sort; ?>">
										Order
									</a>
									<a style="cursor: pointer;" href="javascript: submitform()">
										<img class="save_img" title="Nhấn click để thay đổi thứ tự sắp xếp" src="<?php echo base_url(); ?>images/back_end/save.png" />
									</a>	
			                    </td>
			                    <td width="9%">
			                    	<a class="link_change" title="Click để sắp xếp" href="#">Tác vụ</a>
			                    </td>
			                </tr>
			                
			                <?php
			                $count = 1; 
			                if (count($admin_category_product_2) > 0) {	
			                	foreach ($admin_category_product_2 as $value) {
			                		$count += 1;	 
			                ?> 
				                <tr class="<?php if ($count%2) { echo 'content_ct_show_ct_tbl_bt_1'; } else { echo 'content_ct_show_ct_tbl_bt_2'; }  ?>">
				                    <td class="tdPr7"><input class="input_checkbox" type="checkbox"  value="<?php echo $value['id']; ?>" name="value_id[]"/></td>
				                    <td class="tdPr7">
				                    	<?php echo $value['id']; ?>
				                    </td>
				                    <td class="tdPr7">
				                    	<span><?php echo $value['name']; ?></span>
				                    </td>
				                    <td class="tdPr7">
				                    	<span>
				                    	<?php
				                    		foreach ($ct_1 as $ct_1_arr_c) {
				                    			if($ct_1_arr_c['id'] == $value['parent_id']) {
				                    				echo $ct_1_arr_c['name']; 
				                    			}
				                    		} 
				                    	?>
				                    	</span>
				                    </td>
				                    <td class="tdPr7">
				                    	<span><?php echo $value['keyword']; ?></span>
				                    </td>
				                    <td class="tdPr7">
	                    				<input class="order_admin_menu" value="<?php echo $value['order']; ?>" name="order_category_product_2[<?php echo $value['id']; ?>]" type="text" />
				                    </td>
				                    <td class="tdPr7">
				                    	<?php if($value['status'] == 1) { ?>
				                    		<a class="tag_action" href="<?php echo base_url()?>back_end/category_product_2/active_kh/<? echo $value['id']; ?>"><img src="<?php echo base_url()?>images/back_end/icon/check2.png" title="Trạng thái" alt="icon check" /></a>
				                    	<?php } else { ?>
				                 			<a class="tag_action" href="<?php echo base_url()?>back_end/category_product_2/active_kh/<?php echo $value['id'];  ?>"><img src="<?php echo base_url()?>images/back_end/icon/check.png" title="Trạng thái" alt="icon check" /></a>
				                    	<?php }?>
				                    	<a class="tag_action" href="<?php echo base_url()?>/back_end/category_product_2/edit/<?php echo $value['id']; ?>"><img src="<?php echo base_url()?>images/back_end/icon/edit-icon.gif" alt="Sửa" title="Sửa" /></a>
				                    	<a class="tag_action" href="<?php echo base_url()?>back_end/category_product_2/delete/<?php echo $value['id']; ?>"><img src="<?php echo base_url()?>images/back_end/icon/delete_png.png" title="Xóa"  alt="icon" /></a>
				                    </td>
			                    </tr>
		                    <?php } 
						 	} else {
							?>
							<tr>
								<td colspan="7"><i style="color: #000;">Không có kết quả nào được tìm thấy</i></td>
							</tr> 
						 <?php
						 	} 
						 ?>
		                </table>
	                </div>
				
					<div class="content_ct_show_paging">
						<span style="color: #888;">Tổng số:</span>
						<span style="color: #444;">(<?php echo $this->pagination->total_rows; ?>)</span>
						<?php echo $this->pagination->create_links(); ?>
					</div>
				</div>			
				</form>
				
			</div>
			<!-- end content_ct_show -->
		</div>	